package aufgabe_2_test.try02;

import java.util.ArrayList;

import javax.swing.table.AbstractTableModel;

/**
 * needed class to display the worker information in GUI
 * @author J. Quenzel & R. Flaegel
 *
 */
public class WorkersTableModel extends AbstractTableModel{
	private static final long serialVersionUID = -288556755324682059L;
	/**
	 * reference to the list of worker (only information about 
	 * hostnames, ports and amount worker)
	 */
	ArrayList<WorkerObject> workerList;
	
	public WorkersTableModel(ArrayList<WorkerObject> workerList) {
		this.workerList = workerList;
	}

	@Override
	public int getColumnCount() {
		return 3;
	}

	@Override
	public int getRowCount() {
		return workerList.size();
	}

	@Override
	public Object getValueAt(int arg0, int arg1) {
		switch(arg1){
		case 0: return workerList.get(arg0).getIdentifier();
		case 1: return workerList.get(arg0).getPort();
		case 2: return workerList.get(arg0).getAmountWorkers();
		default: return "undefiniert";
		}
	}
	
	@Override
	public String getColumnName(int column) {		
		switch (column) {
		case 0: return "Hostname";
		case 1: return "Port";
		case 2: return "Anzahl Worker";
		default: return "undefinierte Spalte";
		}

	}
	

}
